package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.ProjectInfoModel;

/**
 * @author liyc
 * @time 2012-4-16 下午7:03:37
 * @annotation 
 */
public class GetXMListTask extends Task {

	public GetXMListTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String pagecount = getParam().get("pagecount").toString();
		String pageindex = getParam().get("pageindex").toString();
		String seamurl = generateURL("Epoint_GetXMList",getFP().getUserguid(),pageindex,pagecount);
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}
	
	public static List<ProjectInfoModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<ProjectInfoModel> plist = new ArrayList<ProjectInfoModel>();
		for (int i = 0; i < focs.size(); i++) {
			ProjectInfoModel mt = new ProjectInfoModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("rowguid") != null)
				mt.rowguid = foc.elementText("rowguid");
			if (foc.element("XiangMuBH") != null)
				mt.XiangMuBH = foc.elementText("XiangMuBH");
			if (foc.element("XiangMuMC") != null)
				mt.XiangMuMC = foc.elementText("XiangMuMC");
			if (foc.element("LiXiangRen") != null)
				mt.LiXiangRen = foc.elementText("LiXiangRen");
			if (foc.element("LiXiangSJ") != null)
				mt.LiXiangSJ = foc.elementText("LiXiangSJ");
			if (foc.element("DiQu") != null)
				mt.DiQu = foc.elementText("DiQu");
			plist.add(mt);
		}
		return plist;
	}

}
